﻿using System.Drawing;


namespace AIthin.Model
{
    public class Pattern : Reality
    {
        /// <summary>
        /// Groesse von der Form
        /// </summary>
        int FormSize;
        /// <summary>
        /// Konstruktor für Pattern
        /// </summary>
        public Pattern(int hight, int width)
            : base(hight, width)
        {
            FormSize = base.Hight / 4;
            base.SetsNumber = 2;
        }
        /// <summary>
        /// Zeichnet alle Elemente.
        /// </summary>
        /// <param name="g">GDI+ Zeichnungsoberfläche</param>
        public override void Draw(Graphics g)
        {
            //hintergrund
            g.FillRectangle(Brushes.White, 0, 0, base.Width, base.Hight);
            g.FillRectangle(Brushes.Black, base.Hight, 0, base.Hight, base.Hight);
            //2 Sets
            g.FillRectangle(Brushes.White, base.Hight, 0, 2, 1);

            switch (base.RandomValue.Next(1, 3))
            {
                case 1: // vertikal
                    {

                        int x = base.Hight / 2 - FormSize / 2 + base.RandomValue.Next(0, FormSize);
                        int y = base.Hight / 2 - FormSize + base.RandomValue.Next(0, FormSize);

                        g.FillRectangle(Brushes.Black, x, y, FormSize, 2 * FormSize);
                        //Output R
                        g.FillRectangle(Brushes.White, base.Hight, 1, base.Hight, 1);
                        break;
                    }
                case 2: // horizontal
                    {
                        //                      int x = base.RandomValue.Next(0, base.Size - 2 * FormSize);
                        //                      int y = base.RandomValue.Next(0, base.Size - FormSize);

                        //jitter
                        int x = base.Hight / 2 - FormSize + base.RandomValue.Next(0, FormSize);
                        int y = base.Hight / 2 - FormSize / 2 + base.RandomValue.Next(0, FormSize);

                        g.FillRectangle(Brushes.Black, x, y, 2 * FormSize, FormSize);
                        //Output R
                        g.FillRectangle(Brushes.White, base.Hight, 2, base.Hight, 1);
                        break;
                    }
            }
        }
        public override void DrawSet(Graphics g, int Set)
        {
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.FillRectangle(Brushes.White, 0, 0, base.Hight, base.Hight);
            g.FillRectangle(Brushes.Black, base.Hight, 0, base.Hight, base.Hight);
            //2 Sets
            g.FillRectangle(Brushes.White, base.Hight, 0, 2, 1);

            switch (Set)
            {
                case 1:
                    g.FillEllipse(Brushes.Black, base.Hight / 2 - FormSize / 2,
                        base.Hight / 2 - FormSize / 2, FormSize, FormSize);
                    //Output R
                    g.FillRectangle(Brushes.White, base.Hight, 1, base.Hight, 1);
                    break;

                case 2:
                    g.FillRectangle(Brushes.Black, base.Hight / 2 - FormSize / 2,
                        base.Hight / 2 - FormSize / 2, FormSize, FormSize);
                    //Output R
                    g.FillRectangle(Brushes.White, base.Hight, 2, base.Hight, 1);
                    break;

                default:
                    break;
            }

        }
    }

}

